//创建一个路由器，并暴露出去

//第一步:引入createRouter
import {createRouter,createWebHistory} from 'vue-router'

//引入组件
import Home from '@/views/Home.vue'
import News from '@/views/News.vue'
import About from '@/views/About.vue'
import Detail from '@/views/Detail.vue'

//第二部：创建路由器
const router = createRouter({
    history:createWebHistory(), //路由器的工作模式
    routes:[
        {
            name:'home',
            path:'/home',
            component:Home

        },
        {
            name:'news',
            path:'/news',
            component:News,
            children:[
                {
                    name:'detail',
                    path:'detail/:id/:title/:content',
                    component:Detail,
                    //第一种写法：将路由收到的所有params参数作为props传给路由组件
                    // props:true

                    //第二种写法，可以自己决定将什么作为props传递给路由组件
                    props(route){
                        return route.params
                    }
                }
            ]

        },
        {
            name:'about',
            path:'/about',
            component:About

        }
    ]
})

export default router